//
//  Article.m
//  iCarStyle
//
//  Created by liunian on 13-9-9.
//  Copyright (c) 2013年 liunian. All rights reserved.
//

#import "Article.h"
#import "NewsEntity.h"
#import "NewsText.h"
#import "NewsImg.h"

@implementation Article



- (NSString *)cName{
    NSArray * cArray = [NSArray arrayWithObjects:@"全部",@"美容知识",@"养护知识",@"维修知识",@"改装知识",@"车居知识",@"汽车用品",@"保险知识", nil];
    if (self.cid < [cArray count]) {
        return [cArray objectAtIndex:self.cid];
    }
    return nil;
}

- (id)initWithNewsEntity:(NewsEntity *)entity{
    self = [super init];
    if (self) {
        [self setNid:[entity.nid integerValue]];
        [self setCid:[entity.cid integerValue]];
        [self setTitle:entity.title];
        [self setDate:entity.date];
        [self setIcon:entity.icon];
        [self setLink:entity.link];
        [self setDesc:entity.desc];
        [self setContent:entity.content];
    }
    return self;
}
@end

@interface NewsArticle ()
@property (nonatomic, strong) NSMutableString *plainText;

@end
@implementation NewsArticle

- (instancetype)instancetypeWithArticle:(Article *)article{
    if (self == [super init]) {
        [self setNid:article.nid];
        [self setCid:article.cid];
        [self setTitle:article.title];
        [self setDate:article.date];
        [self setIcon:article.icon];
        [self setLink:article.link];
        [self setDesc:article.desc];
        [self setContent:article.content];
    }
    return self;
}

- (NSString *)plainText{
    NSMutableString *plainText = [[NSMutableString alloc] init];
    for (NewsText *textNews in self.newsTexts) {
        [plainText appendFormat:@"\n%@\n",textNews.content];
    }

    return plainText;

}
@end